xen/x86: disable global pages for domains with XPTI active
authorJuergen Gross <jgross@suse.com>
Thu, 26 Apr 2018 11:33:14 +0000 (13:33 +0200)
committerWei Liu <wei.liu2@citrix.com>
Fri, 4 May 2018 14:55:06 +0000 (15:55 +0100)
commitd543fa409358a9128d3629dcb28daae28c2d150f
treee1834aa2c31fe75116d58ed032e150d97d5ba12f
parent94a992bccdbf656a5a7a0b585c9f140fccc02674
xen/x86: disable global pages for domains with XPTI active

Instead of flushing the TLB from global pages when switching address
spaces with XPTI being active just disable global pages via %cr4
completely when a domain subject to XPTI is active. This avoids the
need for extra TLB flushes as loading %cr3 will remove all TLB
entries.

In order to avoid states with cr3/cr4 having inconsistent values
(e.g. global pages being activated while cr3 already specifies a XPTI
address space) move loading of the new cr4 value to write_ptbase()
(actually to switch_cr3_cr4() called by write_ptbase()).

This requires to use switch_cr3_cr4() instead of write_ptbase() when
building dom0 in order to avoid setting cr4 with cr4.smap set.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/domain.c
xen/arch/x86/flushtlb.c
xen/arch/x86/mm.c
xen/arch/x86/pv/dom0_build.c
xen/arch/x86/x86_64/entry.S
xen/common/efi/runtime.c
xen/include/asm-x86/domain.h
xen/include/asm-x86/flushtlb.h